home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YPLOT2.C
< prev
next >
Wrap
Text File
|
1988-12-11
|
16KB
|
609 lines
/******************* (C) 1986,7,8 by JAMES A. YORKE **************************/
/******************************** YPLOT2.C ***********************************/
#ifdef IGNORETHIS
EXTERN int corerows INITIAL(COREROWS);
EXTERN int corecols INITIAL(CORECOLS);
EXTERN int scrnrows INITIAL(SCRNROWS);
EXTERN int scrncols INITIAL(SCRNCOLS);
#define CORECOLS 960 /* Width of the internal memory's picture = */
/* The number of bits wide = */
/* width in bits of the printer output */
#define SCRNCOLS 640 /* Width of the crt screen. The program
assumes this is no bigger than CORECOLS */
#define COREROWS 68 /* About the max num of printer lines */
/* that are permited in 64 K */
#define SCRNROWS 200 /* height(bits) of crt screen */
#endif
/* This file YPLOT.C contains routines that are tools
for plotting on the screen and in the core
James Yorke */
/* Routines in YPLOT.c
These are routines that are essentially independent of the map being studied.
add_to_pic in YDISK.C
block_plot(x1,x2,y1,y2)
boot_crt
clearp
connectp(x,y) connects x,y to x_c,y_c
double x,y;
connect2(x1,y1,x2,y2)
cross(x1,y1,m,n,picnum,crossnum) reverses m dots on each side of screen point
(row,col) and n above and below; picnum = 1 means the
screen; = 2 means the core picture
double x1,y1; int m,n,picnum;
definitely_erase_line()
draw_box
erase_line()
fetchPic
fileFailureWarning()
FindPixel(x1,y1,picnum) this routine puts the coordinates in the
vector COL,ROW; if picnum == 1, they are for the crt while
if == 2 they are for the core copy
double x1,y1;int picnum;
maskdef
picOff(COLnum1,ROWnum1,COLnum2,ROWnum2)
int COLnum1,ROWnum1,COLnum2,ROWnum2;
plot(x,y)
PlotComplaint
PrintBoxCoordinates() if printer > 1; prints at top of screen
pprint(onprint) in YPLOT2
resetDiameters
reverseCore(x,y)
ScreenConstants() sets ax,bx where x = 0,00,1,2
scrOff(COLnum1,ROWnum1,COLnum2,ROWnum2)
int COLnum1,ROWnum1,COLnum2,ROWnum2;
int set_box sets X_low thru Y_upp
td
td0 monochrome
double ticGap(dif) dif is double; called by ticMarks
ticMarks() called by draw_box when ticFlag == ON
*/
#include "yinclud.h"
#define BLANK 0
/* char far pic1[CORESIZE]; 65280 = Memory size in core */
extern char far * pic1;
extern char far * pic2;
extern char far * pic4;
extern char far * pic8;
extern char one,
two,
four,
eight; /* bytes for pic arrays */
extern unsigned char byte255;
extern char printstatus; /* set in YPRINTER.C, = status byte of printer;
see also _bios_printer() which is a MSC
function */
static int Contin; /* for interruption by hitting Esc */
pprint(onprint) /* first it initializes the printer; then it
stores picture on disk if "disk" == 1;
prints text header at top of paper if
"printer" > 0 prints pic1[] using codes for
EPSON printer; notice that if "printer" == 0
two pictures can be printed right next to
each other so that by plotting two pictures,
for example an attractor for the henon map
with vertical coord y in 0,2 and the second
picture with y in -2,0, you wind up with a
single double length picture with y running
from -2,2; if you want such a picture for a
differential equation, you should
reinitiallize the picture before each of the
runs so that the curves match up on the
boundary */
int onprint;
{
#ifndef MAINFRAME
int p0;
int checkPrinter();
Contin = YES;
if(disk == 1) /* send picture to disk */
td();
if(checkPrinter () == NO)
return;
fflush(stdprn); /* dumps the computer's file buffer to printer
*/
if(printer > 0) {
line_feed(); /* printer command */
i12print(); /* tells printer to return to regular spacing
*/
print_text(StPrint);
/* prints text header at top of picture */
}
iprint(printerSpacing);/* sets spacing for lines */
/* initial lines that are blank will be skipped; Contin is used to interrupt
printing by hitting space bar */
for(p0 = 0; (Contin == YES) && (p0 < corerows); p0++) {
/* p0 = line number */
/* ************* Now deal with line #p0 **************************
*/
selectPrinterColor(0);/* black */
if(printMode == EPSONBW && Contin == YES)
printScrnColor(0, p0, onprint);
else
if(printMode == EPSONCOLOR && Contin == YES)
LQ2500 (p0, onprint);
/* line has been printed onprint times if onprint > 0 */
line_feed(); /* printer command; needed between lines of
picture */
} /* end p0 */
i12print(); /* tells printer to return to regular spacing
*/
#endif
}
LQ2500 (p0, onprint) /* this is for printing a s 8 bit high line in
color on either an Epson LQ 2500 or LQ 2550
*/
int p0,
onprint;
{ /* note that color plane pic8 is not used */
selectPrinterColor(1);
printScrnColor(5, p0, onprint);/* blue/violet */
selectPrinterColor(2); /* cyan */
printScrnColor(3, p0, onprint);
selectPrinterColor(3);
printScrnColor(1, p0, onprint);/* blue-violet */
selectPrinterColor(4); /* magenta */
printScrnColor(6, p0, onprint);/* brown-yellow */
selectPrinterColor(5); /* red */
printScrnColor(4, p0, onprint);
selectPrinterColor(6);
printScrnColor(2, p0, onprint);/* green */
selectPrinterColor(0); /* */
printScrnColor(7, p0, onprint);
}
printScrnColor(mode, p0, onprint)
int mode,
p0,
onprint;
{
char CharLine[CORECOLS],
getMX80pic();
unsigned i,
coord,
blankLine;
int cs,
keycheck();
int prt;
blankLine = YES; /* initialize as blank so far */
for(i = 0; i < corecols; i++) {/* Is line blank? */
coord = i * corerows + p0;
CharLine[i] = getMX80pic(coord, mode);
if(CharLine[i] != 0)
blankLine = NO;
}
for(prt = 1; prt == 1 || prt <= onprint; prt++) {
cs = keycheck();
if(cs == ESC || cs == ' ')
Contin = NO;
/* space bar stops printing and returns program
to parameter selection */
if(blankLine == YES || Contin == NO)/* then do not print */
return; /* terminates prt loop and we look at next line
*/
else { /* now print line once */
print_graphics_mode();
for(i = 0; i < corecols; i++) {
/* putc(CharLine[i],stdprn);
fflush(stdprn);
*/ C = CharLine[i];
printChar();
}
carriage_return();
} /* end else */
} /* end prt */
}
HPLine(p0) /* this is for printing an 8 bit high line in
color */
int p0;
{
int bit;
rasterColorPlanes(4); /* Esc*r4U */
/* Esc*r0A */
setRasterMode(); /* =Esc*r0A, specifies graphics start at left
margin */
for(bit = 0; bit < 8; bit++) {
set90RasterMode();
rasterByte(pic1 + p0, bit);
set90RasterMode();
rasterByte(pic2 + p0, bit);
set90RasterMode();
rasterByte(pic4 + p0, bit);
setLast90RasterMode();
rasterByte(pic8 + p0, bit);
}
exitRasterMode();
}
HPColorRaster(pic, bit) /* this is for specifying a 1-bit-high line of
1 color plane */
int bit;
char *pic;
{
int j;
unsigned plus = 8 * corerows;
for(j = 0; j < 90; j++, pic += plus) {
rasterByte(pic, bit);
printChar();
}
}
rasterByte(pic, bit) /* This takes the bit number "bit" out of 8
bytes that start at address pic and combine
them into one byte which is sent to the
printer */
char *pic;
int bit;
{
unsigned char B = mask[bit];
C = 0;
if(((*pic) & B) != 0)
C = 1;
pic += corerows;
if(((*pic) & B) != 0)
C += 2;
pic += corerows;
if(((*pic) & B) != 0)
C += 4;
pic += corerows;
if(((*pic) & B) != 0)
C += 8;
pic += corerows;
if(((*pic) & B) != 0)
C += 16;
pic += corerows;
if(((*pic) & B) != 0)
C += 32;
pic += corerows;
if(((*pic) & B) != 0)
C += 64;
if(((*(pic + 7)) & B) != 0)
C += 128;
printChar();
return;
}
rasterColorPlanes(c) /* HP PAINTJET :number of color planes */
int c;
{
C = ESC;
printChar();
C = '*';
printChar();
C = 'r';
printChar();
C = '0' + c;
printChar();
C = 'U';
printChar();
}
/* Esc*r0A */
setRasterMode() { /* HP PAINTJET */
C = ESC;
printChar();
C = '*';
printChar();
C = 'r';
printChar();
C = '0';
printChar();
C = 'A';
printChar();
}
exitRasterMode() { /* HP PAINTJET */
C = ESC;
printChar();
C = '*';
printChar();
C = 'r';
printChar();
C = 'B';
printChar();
}
set90RasterMode() { /* HP PAINTJET: says 90 bytes for each color
plane; this or setLastRasterMode must preced
each line of bytes */
C = ESC;
printChar();
C = '*';
printChar();
C = 'b';
printChar();
C = '9';
printChar();
C = '0';
printChar();
C = 'V';
printChar();
}
setLast90RasterMode() { /* HP PAINTJET: says 90 bytes for last color
plane */
C = ESC;
printChar();
C = '*';
printChar();
C = 'b';
printChar();
C = '9';
printChar();
C = '0';
printChar();
C = 'W';
printChar();
}
char getMX80pic(coord, mode)/* gets one character */
unsigned coord,
mode;
{
char pc1,
pc2,
pc4,
pc8;
if(mode == 0) {
if(colorPlanes >= 1)
pc1 = pic1[coord];
else
pc1 = 0;
if(colorPlanes >= 2)
pc2 = pic2[coord];
else
pc2 = 0;
if(colorPlanes >= 3)
pc4 = pic4[coord];
else
pc4 = 0;
if(colorPlanes >= 4)
pc8 = pic8[coord];
else
pc8 = 0;
return(pc1 | pc2 | pc4 | pc8);
}
if(mode == 1)
return((pic1[coord] & ~pic2[coord]) & ~pic4[coord]);/* 1 */
if(mode == 2)
return((~pic1[coord] & pic2[coord]) & ~pic4[coord]);/* 2 */
if(mode == 3)
return((pic1[coord] & pic2[coord]) & ~pic4[coord]);/* 3 */
if(mode == 4)
return((~pic1[coord] & ~pic2[coord]) & pic4[coord]);/* 4 */
if(mode == 5)
return((pic1[coord] & ~pic2[coord]) & pic4[coord]);/* 5 */
if(mode == 6)
return((~pic1[coord] & pic2[coord]) & pic4[coord]);/* 6 */
if(mode == 7)
return((pic1[coord] & pic2[coord]) & pic4[coord]);/* 7 */
return((char) 0); /* dumby return */
}
#ifndef MAINFRAME
int checkPrinter() {
int printerstatus;
char ch;
char what_me_worry();
int keycheck();
printerStatus(1); /* initializes the printer */
printerStatus(2); /* returns status byte; it returns an integer
(but not here); meaning of bit: 7 printer
busy 6 Acknowledge 5 out of paper 4
selected 3 I/O error 2,1 not used 0
timed out */
if(printstatus != 0)
PRINT
"printer status = %d; bit# 0= %d 1= %d 2= %d 3= %d 4= %d 5= %d 6 %d 7 %d\n"
,printerstatus = printstatus
,printerstatus = printstatus & mask[7]
,printerstatus = printstatus & mask[6]
,printerstatus = printstatus & mask[5]
,printerstatus = printstatus & mask[4]
,printerstatus = printstatus & mask[3]
,printerstatus = printstatus & mask[2]
,printerstatus = printstatus & mask[1]
,printerstatus = printstatus & mask[0]);
printerstatus = printstatus & mask[4];
if(printerstatus != 0) {/* this is called bit 3; they seem to count
from the other end; */
PRINT
"WARNING: printer I/O error detected; perhaps printer is off; \n");
ch = what_me_worry();/* gives warning and gets response */
if(ch != 'y' && ch != 'Y')
return(NO);
}
printerstatus = printstatus & mask[2];
if(printerstatus != 0) {/* called bit 5 */
PRINT
"WARNING: printer error; perhaps printer is out of paper.\n");
ch = what_me_worry();/* gives warning and gets response */
PRINT
"** %c **\n", ch);
if(ch != 'y' && ch != 'Y')
return(NO);
}
return(YES);
}
char what_me_worry() { /* called in case a problem with the printer
has been detected */
PRINT
"Proceed with attempt to print only if picture is stored; program might \n"
);
PRINT
"hang up. DO YOU WANT TO PROCEED WITH PRINT ATTEMPT? enter Y or N:\n");
return(ci ());
}
setRGBColor()/* called by 'Q' for VGA only;
first enter color number and the 3 shades; */
{
char * text;
long Color;
int cnum1 = -1;
int cnum2 = -1,colnum;/* color nubers */
int r1,r2=0,b1,b2=0,g1,g2=0;/* shades */
double f,g;
text =
"Enter another (with larger color number);program will interpolate between\n";
if (SCREEN && printer > 1)
{
displayColors(.0,.1);
PRINT
"\nEnter color number (< %d) and red, green and blue shades (all < 64) \n",
numColors);
}
colnum = -1;
Enter4Int(&colnum,&rColor,&gColor,&bColor);
Color = rColor + gColor*(_GREEN/_RED) + bColor*(_BLUE/_RED);
_remappalette(colnum,Color);/*notice spelling:pp has special meaning */
for(;;)
{
cnum1 = colnum;
if (cnum1 < 0)
return; /* nothing is set */
r1 = rColor;
g1 = gColor;
b1 = bColor;
scr_rowcol(0,0);
if (SCREEN)
PRINT text);
if (SCREEN)
PRINT
"YOU MUST Hit <Enter> TO TERMINATE COLOR SPECIFICATION \n");
if (SCREEN)
PRINT text);
Enter4Int(&cnum2,&r2,&g2,&b2);
if (cnum2 <= cnum1)
return; /* nothing more is set */
g = cnum2 - cnum1;
for (colnum = cnum1; colnum <= cnum2 ;colnum++)
{
f = (cnum2 - colnum)/g;
rColor = (f*r1 + (1-f)*r2);
gColor = (f*g1 + (1-f)*g2);
bColor = (f*b1 + (1-f)*b2);
Color =
rColor + bColor*(_BLUE/_RED) + gColor*(_GREEN/_RED);
displayColors(.0,.1);
_remappalette(colnum,Color);
if (numColors == 255)
scr_rowcol(0,0);
}
if (cnum2 == numColors)
return; /* nothing more can be set */
}
}
displayColors(f0,f1)/* f0 and f1 are in 0 to 1 and are the fractions of the
vertical scale (from 0 at bottom to 1.0 at top) that the
color bars will occupy; this is screen only, not core picture*/
double f0,f1;
{
double x1,x2,y1,y2;
double f;
unsigned k;
y1 = (1-f0)*Y_lower+f0*Y_upper;
y2 = (1-f1)*Y_lower+f1*Y_upper;
for (k=0; k<numColors; k++)/* display 16 colors */
{
_setcolor(k);
f = k/((double)numColors);
x1 = (1-f)*X_lower + f*X_upper;
f = (k+1)/((double)numColors);
x2 = (1-f)*X_lower + f*X_upper;
scrnBlock_plot(x1,x2,y1,y2);
}
_setcolor(color);
}
scrnBlock_plot(x1,x2,y1,y2)
double x1,x2,y1,y2;
{
unsigned coord;
int COLnum1,
COLnum2,
ROWnum1,
ROWnum2;
FindPixel(x1,y1, SCRN);/*sets COL and ROW */
COLnum1 = COL;
ROWnum1 = ROW;
FindPixel(x2, y2, SCRN);
COLnum2 = COL;
ROWnum2 = ROW;
_rectangle(_GFILLINTERIOR,COLnum1,ROWnum1,COLnum2,ROWnum2);
#ifdef IGNORE
for(COL = COLnum1; COL < COLnum2; COL++)/* COL is an int */
for(ROW = ROWnum1; ROW < ROWnum2; ROW++)
setPixel(COL, ROW, k);
#endif /*IGNORE */
}
#endif /* ifndef MAINFRAME */
/* universal color values:
#define _BLACK 0x000000L 0 0 0
#define _BLUE 0x2a0000L 2 0 0 where 2 = 42
#define _GREEN 0x002a00L 0 2 0
#define _CYAN 0x2a2a00L 2 2 0
#define _RED 0x00002aL 0 0 2
#define _MAGENTA 0x2a002aL 2 0 2
#define _BROWN 0x00152aL 0 1 2 where 1 = 21
#define _WHITE 0x2a2a2aL 2 2 2
#define _GRAY 0x151515L 1 1 1
#define _LIGHTBLUE 0x3F1515L 3 1 1 where 3 = 63
#define _LIGHTGREEN 0x153f15L 1 3 1
#define _LIGHTCYAN 0x3f3f15L 3 3 1
#define _LIGHTRED 0x15153fL 1 1 3
#define _LIGHTMAGENTA 0x3f153fL 3 1 3
#define _LIGHTYELLOW 0x153f3fL 1 3 3
#define _BRIGHTWHITE 0x3f3f3fL 3 3 3
*/